package com.yuexun.dhdoctor.module.contractmanage.presenter.impl;




import com.yuexun.dhdoctor.base.BaseEntity;
import com.yuexun.dhdoctor.module.contractmanage.bean.ContractManageInspectBean;
import com.yuexun.dhdoctor.module.contractmanage.model.IContractManageModel;
import com.yuexun.dhdoctor.module.contractmanage.presenter.IContractManageInspectPresenter;
import com.yuexun.dhdoctor.module.contractmanage.ui.view.IContractManageInspectView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by work-jx on 2016/10/26.
 */
public class ContractManageInspectPresenter implements IContractManageInspectPresenter {
    private IContractManageInspectView view;
    private IContractManageModel model;

    public ContractManageInspectPresenter(IContractManageInspectView view, IContractManageModel model)
    {
        this.view = view;
        this.model = model;
    }


    @Override
    public void showContractManageInspectList(Map<String, String> praise) {
        model.inquireCheckPageList(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<BaseEntity<ContractManageInspectBean>>() {
                               @Override
                               public void onCompleted() {

                               }

                               @Override
                               public void onError(Throwable e) {
                                   ViewInject.toast("获取数据失败:"+e.getMessage());
                               }

                               @Override
                               public void onNext(BaseEntity<ContractManageInspectBean> contractManageInspectBeanBaseEntity) {
                                   view.showContractManageInspectList(contractManageInspectBeanBaseEntity);
                               }
                           }
                );
    }
}
